package org.example.multiThreading.ThreadMethod;

public class MyThreadPriority {
    public static void main(String[] args) {
        TestThreadPriority priority4 = new TestThreadPriority("4号线程,优先级1");
        TestThreadPriority priority1 = new TestThreadPriority("1号线程,优先级5");
        TestThreadPriority priority2 = new TestThreadPriority("2号线程,优先级5");
        TestThreadPriority priority3 = new TestThreadPriority("3号线程,优先级10");
        //设置线程优先级
        priority4.setPriority(1);
        priority3.setPriority(10);
        //启动线程
        priority4.start();
        priority2.start();
        priority1.start();
        priority3.start();
    }
}
class TestThreadPriority extends Thread{

    public TestThreadPriority(String name){
        super(name);
    }

    @Override
    public void run(){
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"-"+i);
        }
    }
}